<?php
$dbh= null;

function dbh_connect(){
	global $dbh;
	
	$srvr= "localhost";
	$user= "root";
	$pass= "";
	$db= "geret";
	//$db= "photodpt_geret";
	
	$dbh=mysqli_connect($srvr,$user,$pass,$db);
	if(!isset($dbh)){
		echo fks_msg_handler(CONEXION_ERROR);
		return false;
	}
	//para arreglar el tema de los acentos
	mysqli_query($dbh,"set names 'iso-8859-1'");
	return $dbh!=null;
}

function dbh_disconnect(){
	global $dbh;
	if(isset($dbh)) mysqli_close($dbh);
	$dbh=null;
}

function dbh_query($cmd){
	global $dbh;
	dbh_disconnect();
	if(!isset($dbh)){
		if(!dbh_connect()) return false;
	}
	$data= mysqli_query($dbh,$cmd);
	if(!isset($data)){ 
		echo fks_msg_handler(QUERY_ERROR);
	}
	return $data;
}

function dbh_fetch($data){
	if($data) return mysqli_fetch_array($data);
	return null;
}
?>